package com.sui.bigdata.rtcadmin.product;

import com.feidee.fdcommon.model.StringResponse;
import com.feidee.fdcommon.util.HttpUtil;
import org.apache.http.Consts;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;

/**
 * @author YongChen
 * @date 2020/1/10 14:24
 * @description
 * @email yong_chen@sui.com
 */
public class restart {

    public static void main(String[] args) throws Exception {


        String url = "http://adam.feidee.com/rtc-admin/job?action=restart";


//        String data = "{\"jobName\":\"flink_onlinead_realtime_report\"," +
//                "\"extendParam\":{\"time.characteristic\":\"ProcessingTime\",\"sql.checkpoint.interval\":300000,\"sql.ttl.min\":\"2d\",\"sql.ttl.max\":\"3d\",\"state.checkpoints.dir\":\"hdfs://nameservice1/data_team/flink/checkpoint/onlinead_realtime_report_streamsql\"}}";
//        String data = "{\"jobName\":\"flink_onlinead_realtime_report\",\"taskManagerMemory\":\"3072\",\"savepoint\":\"true\"}";

        String data = "{\"jobName\":\"flink_model_deviceBehaviourLocation_platform\",\"savepoint\":\"true\"}";


        System.out.println(data);
        StringEntity stringEntity = new StringEntity(data, Consts.UTF_8);
        stringEntity.setContentEncoding("UTF-8");
        stringEntity.setContentType("application/json");
        HttpPost httpPost = new HttpPost(url);

        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(500000).build();
        httpPost.setEntity(stringEntity);
        httpPost.setConfig(requestConfig);
        StringResponse response = HttpUtil.post(httpPost);
        System.out.println(">>>>> " + response.getResponseBody());
    }

}
